function red() {
    console.log('red');
}
function yellow() {
    console.log('yellow');
}
function green() {
    console.log('green');
}

function circle() {
    setTimeout(() => {
        red()
        setTimeout(() => {
            yellow()
            setTimeout(() => {
                green()
                circle()
            },2000)
        },1000)
    },3000)
}
circle()